/*****************************************************************/ /**
 * \file   platform_config.h
 * \brief  platform port config define
 * 
 * \author monster
 * \date   April 2024
 *********************************************************************/
#ifndef __PLATFORM_CONFIG_H
#define __PLATFORM_CONFIG_H

/*=======================
 * MCU Config
 *=======================*/
#define FREQ_1M_HZ                          1000000

/**
 * System
 */
#ifndef F_CPU
#define F_CPU                               (168 * FREQ_1M_HZ)
#endif

/**
 * Tick
 */
#define SYSTICK_TICK_FREQ                   1000 // Hz

/**
 * Hardware Serial
 */
/* cache buffer size */
#define SERIAL_BUFFER_SIZE					64
/* port callback */
#define SERIAL_BEGIN(uart,baud)             uartInit(uart,baud)
#define SERIAL_WRITE(uart,buff,size)        uartWrite(uart,buff,size)
#define SERIAL_READ(uart,buff,size)         uartRead(uart,buff,size)
#define SERIAL_EVENT_HANDLER(uart,event,size)   uartEventCallback(uart,event,size)
/* enable select */
#define SERIAL_1_ENABLE                     1
#define SERIAL_2_ENABLE                     0
#define SERIAL_3_ENABLE                     0
/* serial obj */
#if SERIAL_1_ENABLE
#   define SERIAL_1_OBJ						&huart2
#endif

#if SERIAL_2_ENABLE
#   define SERIAL_2_OBJ						&huart6
#endif

#if SERIAL_3_ENABLE
#   define SERIAL_3_OBJ						&huart6
#endif

/**
 * i2c
 */
/* cache buffer size */
#define I2C_BUFFER_SIZE                     16
/* port callback */
#define I2C_BEGIN(i2c,freq)						i2cBegin(i2c,)
#define I2C_WRITE(i2c,dev,buff,size,stop)		i2cWrite(i2c,dev,buff,size,stop)
#define I2C_READ(i2c,dev,buff,size,stop)		i2cRead(i2c,dev,buff,size,stop)
#define I2C_REG_READ(i2c,dev,reg,addrSize,buff,size)	i2cRegRead(i2c,dev,reg,addrSize,buff,size)
#define I2C_REG_WRITE(i2c,dev,reg,addrSize,buff,size)	i2cRegWrite(i2c,dev,reg,addrSize,buff,size)
#define I2C_EVENT_HANDLER(i2c,event,size)		i2cEventCallback(i2c,event,size)
/* enable select */
#define I2C_1_ENABLE                        1
#define I2C_2_ENABLE                        0

/* i2c obj */
#if I2C_1_ENABLE
#	define I2C_1_OBJ						&hi2c1
#endif

#if I2C_2_ENABLE
#	define I2C_2_OBJ						&hi2c1
#endif

#endif    /*__PLATFORM_CONFIG_H*/
